package me.zhengjie.minbearwcs.controller.exception;

import lombok.extern.slf4j.Slf4j;
import me.zhengjie.minbearwcs.entity.DTO.response.Resp;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@ControllerAdvice(basePackages = "me.zhengjie.minbearwcs")
public class WcsControllerException {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Resp handler1(Exception e) {
//        MDC.put(LogFileKey.KEY, LogFileKey.Module.CAR);
        log.error("wcs信息处理失败", e);
//        HashMap<String, String> resultMap = new HashMap<>();
//        // 1:表示 OK -1:表示 NG
//        resultMap.put("returnCode", "-1");
//        resultMap.put("returnReason", "车体交管信息处理失败");
//        MDC.remove(LogFileKey.KEY);
        return Resp.build()
                .code(false)
                .reason("处理信息失败");
    }

}
